package cn.kgm.sqlSession;

import cn.kgm.config.XMLConfigBuilder;
import cn.kgm.pojo.Configuration;
import org.dom4j.DocumentException;

import java.io.InputStream;

public class SqlSessionFactoryBuilder {

    private Configuration configuration;

    public SqlSessionFactory build(InputStream inputStream) throws DocumentException {

        // 1. 解析配置文件,封装容器对象XMLConfigBuilder:专门解析核心配置文件的解析类
        XMLConfigBuilder xmlConfigBuilder = new XMLConfigBuilder();
        // 在这里完成真正的表达式解析工作
        Configuration configuration = xmlConfigBuilder.parse(inputStream);

        DefaultSqlSessionFactory defaultSqlSessionFactory = new DefaultSqlSessionFactory(configuration);

        return defaultSqlSessionFactory;
    }
}
